//var api='http://39.105.232.86:9091/'
var api='http://127.0.0.1:9091/'
var baseUrl='http://39.100.94.200:81/'
//var loginUrl='http://127.0.0.1:63343/BackgroundManagementSystem/page/system/login/login.html';
//下次再发ajax请求把token带到后台
var token = $.cookie('TOKEN');
var ADMINNAME = $.cookie('name');

//给页面显示登陆用户名

$("#admin_name").html(ADMINNAME);

$.ajaxSetup({
    headers:{
        'TOKEN':token
    }
})
//如果访问登陆页面这外的页面并且还没有登陆成功之后写入cookie的token就转到登陆页面
if(token==undefined){
    if(window.location!=loginUrl){
        window.top.location=loginUrl;
    }
}else{
    if(window.location!=loginUrl){
        $.ajax({
            url:api+"login/checkLogin",
            async:true,
            type:'post',
            dataType:'json',
            success:function(res){
                if(res.code==-1){
                    window.top.location=loginUrl;
                }
            },
            error:function(res){
                window.top.location=loginUrl;
            }
        });
    }
}
